<template>
  <!-- 设置高龄货物天数 -->
    <el-dialog title="设置高龄货物天数" :visible.sync="openHighAgeDaysEdit" width="500px" append-to-body :destroy-on-close="true" :before-close="beforeClose">
      <el-form ref="form" :model="formParams" label-width="150px" :inline="true">
        <el-form-item label="设置高龄货物天数" prop="c1">
          <el-input
            v-model="formParams.c1"
            placeholder="请输入高龄货物天数"
            clearable
          />
        </el-form-item>
        <el-row class="mt20" type="flex" justify="center">
          <el-col :span="1.5">
            <el-button type="primary" size="mini" @click="handleEdit" v-hasPermi="['zhcloud:sjzl:modify']">修 改</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
</template>

<script>
import { setHighAgeDays, getHighAgeDays  }  from "@/api/storage/dataOverview/goodsOverview";

export default {
  name: "HighAgeDaysEdit",
  data() {
    return {
      //窗口状态
      openHighAgeDaysEdit:false,
      //高龄天数
      highAgeDays:0,
      //显示参数
      formParams: {
        c1:""
      },
    };
  },
  methods: {
      /**获取高龄天数 */
    getHighAgeDays() {
      getHighAgeDays(this.formParams).then(response => {
        this.formParams.c1 = response.data.c1
      }).catch(()=> {})
    },
    /**修改 */
    handleEdit() {
      this.$modal.loading("数据正在修改中，请稍等...")
      setHighAgeDays(this.formParams).then(response => {
        this.$modal.closeLoading()
        this.close()
        this.$emit('refresh', true)
      }).catch(()=> {
        this.$modal.closeLoading()
      })
    },

    /**改变窗口状态 */
    changeHighAgeDaysEdit() {
      this.openHighAgeDaysEdit = !this.openHighAgeDaysEdit;
    },
    /**重置数据 */
    reset(vm) {
      Object.assign(vm.$data, vm.$options.data())
    },
    /**关闭弹窗 */
    beforeClose(done) {
      this.close()
      done()
    },
    /**关闭弹窗 */
    close() {
      this.changeHighAgeDaysEdit()
      this.reset(this)
    },
    /**打开弹窗 */
    open() {
      this.changeHighAgeDaysEdit()
      this.getHighAgeDays()
    }
  }
};
</script>
